<template>
  <div>
    <p class="u-title">@我的</p>
    <ul class="my-box">
      <li v-for="item in arr" :key="item.id">
        <img class="avatarUrl" :src="item.json.comment.user.avatarUrl" alt="" />
        <div class="item-right">
          <p>
            <span>{{ item.json.comment.user.nickname }}</span>
            评论
            <span class="time">
              {{ item.json.comment.time | fmtDate("MM月DD日 hh:mm") }}
            </span>
          </p>
          <p>{{ item.json.comment.content }}</p>
          <div class="resource-box">
            <img
              class="blurPicUrl"
              :src="item.json.resource.album.blurPicUrl"
              alt=""
            />
            <div>
              <p class="music-name">
                {{ item.json.resource.album.name }}
              </p>
              <p>
                <span
                  v-for="itemTwo in item.json.resource.album.artists"
                  :key="itemTwo.id"
                  class="singer-name"
                  >{{ itemTwo.name }}</span
                >
              </p>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { getmy } from "@/api";
import None from "@/views/News/nona.vue";
export default {
  components: {
    None,
  },
  data() {
    return {
      limit: 20,
      arr: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      getmy({ limit: this.limit, uid: this.$route.query.id }).then((res) => {
        this.arr = res.forwards.map((item) => {
          item.json = JSON.parse(item.json);
          return item;
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.my-box {
  margin-top: 10px;
  li {
    display: flex;
    border-bottom: 1px dotted #ccc;
    padding: 16px 0;
    .avatarUrl {
      width: 50px;
      height: 50px;
      margin-right: 10px;
    }
    .item-right {
      flex: 1;
      p {
        font-size: 14px;
        color: #666;
        margin-bottom: 10px;
        span {
          color: #0c73c2;
        }
        .time {
          color: #666;
          font-size: 12px;
          float: right;
        }
      }
      .resource-box {
        display: flex;
        background: #f5f5f5;
        padding: 10px;
        margin: 4px 0 5px;
        .blurPicUrl {
          width: 40px;
          height: 40px;
          margin-right: 10px;
        }
        .music-name {
          color: #333;
          margin-bottom: 0;
        }
        .singer-name {
          color: #666;
          font-size: 12px;
        }
      }
    }
  }
}
</style>